package features.advance.jdk.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.JedisSentinelPool;

import java.util.HashSet;
import java.util.Set;

/**
 * @author LIN
 * @date 2021-07-19
 */
public class JedisDemo {

    public static void main(String[] args) {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(10);
        jedisPoolConfig.setMaxIdle(5);
        jedisPoolConfig.setMinIdle(5);
        Set<String> set = new HashSet<>();
        set.add("10.133.79.86:26379");
        JedisSentinelPool pool = new JedisSentinelPool("mymaster", set, jedisPoolConfig, null);
        Jedis jedis = pool.getResource();
        jedis.set("mykey","myvalue");
        String myvalue = jedis.get("mykey");
        System.out.println(myvalue);

    }


}
